package com.scut.scutzone.dao;

import com.scut.scutzone.entity.Post;
import org.apache.ibatis.annotations.Param;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

/**
 * @Author: hg chen
 * @Date: 2021/4/29
 * @Time: 19:31
 * @Description:
 */
@Repository
public interface PostAccess {

    List<Post> getPostByUserId(@Param("user_id")int user_id);

    Post getPostByPostId(@Param("post_id")int id);

    int updateDeleteTimeByPostId(@Param("post_id")int id, @Param("delete_at")Timestamp currentTime);

    //int addPost(@Param("user_id")int user_id,@Param("content")String content,@Param("imgs_name")String imgs_name);

    int addPost(@Param("post")Post post);

    int updatePost(@Param("post_id")int id,@Param("content")String content,@Param("imgs_name")String[] imgs_name);

    void adjustCommentsNum(@Param("post_id")int post_id,@Param("increase")boolean increase);

    void updateCommentsNum(@Param("post_id")int post_id,@Param("comments_num")int comments_num);

    List<Post> searchPost(@Nullable @Param("user_id") Integer user_id,@Nullable @Param("keyword")String keyword,@Param("offset")Integer offset,@Param("limit")Integer limit);
}
